<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP '销售订单' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script type="text/javascript" src="<%=basePath%>/javascript/mootools.js"></script>
		<script type="text/javascript" src="<%=basePath%>/javascript/mootools-jsonp.js"></script>
		<script type="text/javascript" src="<%=basePath%>/javascript/Servlet.js"></script>

		<script type="text/javascript">
		var url = "<%=basePath%>/servlet/SalesOrderServlet"
		function addSoSomain(){
			var somain = new Servlet("addSoSomain");
			somain.data.ccusCode = "03001";//客户编码 根据客户列表获取
			somain.data.ccusName = "神话大房间";//客户名称 根据客户列表获取 对应的名称
			somain.data.cdefine11 = "神话大房间";//使用单位名称 根据使用单位列表获取
			somain.responseCall = addSuccess;
			somain.submit(url);
		}
		
		
		function addSuccess(json,text){
			alert("添加成功"+json.message); // 主表的编号和ID, 附表有用 中编号和ID中间用逗号区分
		}
		
		
		function addSoSodetails(){
			var details = new Servlet("addSoSodetails");
			details.data.cinvName = "订书针2";//存货名称
			details.data.cinvCode = "10";//存货编码
			details.data.csocode = "0000000005"; // 对应主表的编号, 添加主表成功后的返回值;
			details.data.id = "10";//主表返回的ID 添加主表成功后的返回值;
			details.data.iquantity = "12";// 数量
			details.data.iquotedPrice = "157.5";//售价
			details.data.iunitPrice = "2.00";//原币无税单价
			details.data.inatUnitPrice = "2.00";//同上
			details.data.itaxUnitPrice = "2.34";//原币含税单价
			details.data.imoney = "10.34";//金额 , 单价* 数量
			details.data.inatMoney = "10.34";//同上
			details.data.itax = "13.001";//税额, 就是 imoney*0.17
			details.data.inatTax = "13.001";//同上
			details.data.isum = "13.001";//价格和税额 合计金额, 就是 itax + itax
			details.data.inatSum = "13.001";//同上
			details.data.irowNo = "2";//子订单按照1,2,3排列顺序号 例如:如果当前订单下再增一个子订单, 序号为2
			
			details.responseCall = addSuccess;
			details.submit(url);
		}
		
	</script>

	</head>

	<body>
		<li>
			<input type="button" value="addSoSomain"
				onclick="addSoSomain()">
		<li>
			<input type="button" value="addSoSodetails"
				onclick="addSoSodetails()">
	</body>
</html>
